package com.fumihiko.modules.wsbj.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.fumihiko.modules.wsbj.entity.TbTokenEntity;
import com.fumihiko.modules.wsbj.service.TbTokenService;
import com.fumihiko.common.utils.PageUtils;
import com.fumihiko.common.utils.R;



/**
 * ${comments}
 *
 * @author hanwenpeng
 * @email devilzwy@gmail.com
 * @date 2022-01-19 10:09:51
 */
@RestController
@RequestMapping("wsbj/tbtoken")
public class TbTokenController {
    @Autowired
    private TbTokenService tbTokenService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("wsbj:tbtoken:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbTokenService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("wsbj:tbtoken:info")
    public R info(@PathVariable("id") Long id){
		TbTokenEntity tbToken = tbTokenService.getById(id);

        return R.ok().put("tbToken", tbToken);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("wsbj:tbtoken:save")
    public R save(@RequestBody TbTokenEntity tbToken){
		tbTokenService.save(tbToken);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("wsbj:tbtoken:update")
    public R update(@RequestBody TbTokenEntity tbToken){
		tbTokenService.updateById(tbToken);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("wsbj:tbtoken:delete")
    public R delete(@RequestBody Long[] ids){
		tbTokenService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
